package com.have.blog.commons.config.feign;

import feign.RequestInterceptor;
import feign.auth.BasicAuthRequestInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;

/**
 * feign的配置文件【配置Springsecurity校验，Feign拦截器】
 */
@Configuration
public class FeignConfiguration {
    /**
     * SpringSecurity校验拦截器
     * 在通信的微服务上设置相同的账号密码，如果账号密码不相同就会拒绝请求
     * @return
     */
    @Bean
    public BasicAuthRequestInterceptor basicAuthRequestInterceptor() {
        return new BasicAuthRequestInterceptor("user", "password123");
    }

    /**
     * Feign请求拦截器
     */
    @Bean
    public RequestInterceptor requestInterceptor() {
        return new FeignBasicAuthRequestInterceptor();
    }
}
